package lesson12;

import java.io.Serializable;

/**
 * 学生类
 */
public class Student implements Comparable<Student>, Serializable {
    private String name;
    private int age;
    private String gender;


    public Student() {
    }
    public Student(String name) {
        this.name = name;
    }
    public Student(String name, int age, String gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public boolean equals(Object obj){
        Student stu = (Student) obj;
        if(this.name.equals(stu.getName())){
            return true;
        }
        return false;
    }
    public int hashcode(){
        return this.name.hashCode();
    }

    @Override
    public String toString() {
        return "" + name + '\'' +
                "," + age +
                ",'" + gender + '\'';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    @Override
    public int compareTo(Student o) {
        return this.getAge() - o.getAge();
    }
}
